#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

vector<long long> e[5555];
long long temp[5555] = {};
int mt[5555] = {};

void dfs(int index)
{
    if (temp[index])
    {
        return;
    }
    
    long long rst = 0;
    for (int i = 0; i < e[index].size(); i++)
    {
        dfs(e[index][i]);
        rst += temp[e[index][i]];
        rst %= 80112002;
    }

    if (!rst) rst = 1;

    temp[index] = rst % 80112002;
}

int main(int argc, char const *argv[])
{
    int n, m, a, b;
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        cin >> a >> b;
        e[b].push_back(a);
        mt[a] = 1;
    }
    for (int i = 1; i <= n; i++)
    {
        dfs(i);
    }
    int rst = 0;
    for (int i = 1; i <= n; i++)
    {
        if (!mt[i])
        {
            rst += temp[i];
            rst %= 80112002; 
        }
    }
    
    cout << rst % 80112002;

    return 0;
}
